/*
This file replicates the analyses reported in 
Hohendorf, Sieberer, Wenzig (2023): Recorded votes as attention booster.
	How opposition parties use roll-calls and non-recorded votes for 
	position-taking in the German Bundestag, 2017-2021, 
	Legislative Studies Quarterly, doi: doi: 10.1111/lsq.12442
	
To run the file, please 
- choose a working directory on your computer
- copy the datasets 
	"EveryBundestagVote_VoteLevel.dta" and 
	"use EveryBundestagVote_PartyLevel.dta" 
  from Harvard Dataverse to your working directory+
- set your working directory right after this comment section
- run this do-file
*/


*SET YOUR WORKING DIRECTORY in the next line below between the quotation marks

cd "PUT_YOUR_WD_HERE"

clear
macro drop _all
local c_date = c(current_date)
local date_string = subinstr("`c_date'", " ", "_", .)

// Name: 	Replication_Recorded_votes_as_attention_boosters
// Task: 	Replication of Analyses for "Recorded votes as attention boosters"
// Authors:	Lukas Hohendorf, Ulrich Sieberer / December 06, 2023

version 16.0
set more off


*PASTE your working directory HERE!
*cd ""

capture log close
log using replication_Hohendorf_et_al_LSQ_`date_string'.log, replace text

*********************************************
*** A ANALYSIS OF RCV REQUEST (MOTION LEVEL)
*********************************************

use EveryBundestagVote_VoteLevel.dta, clear




** A.1. Descriptive information
*****************************

// number of votes and share of RCVs
tab recorded

** A.2. Models of RCV request
***************************

* A.2.1. Estimate models
**********************
// all votes on motions, bills, resolutions except troop deployment 
// (Model 1 in Tab A.1)

logit recorded i.currenttop i.motiontype ib2.sponsor_cat ib4.cyc ///
	if motiontype<4 & bundeswehreinsatz==0, or
est store request_all

// only votes on bills (Model 2 in Tab. A.1)
logit recorded i.currenttop ib2.sponsor_cat i.final_debate ib4.cyc ///
	if motiontype==3, or
est store request_bills

* A.2.2 Coefficient plot (Figure 1)
**********************************
coefplot (request_all, label("(1) Sample: all votes w/o troop deployment") ///
	mcolor(black) ciopts(lcolor(black))) ///
	(request_bills, label("(2) Sample: bills") ///
	mcolor(gs10) ciopts(lcolor(gs10))),xline(1,lcolor(black) lwidth(.2)) ///
	drop(_cons) ///
	coeflabels(1.currenttop = "Salient policy area" ///
               2.motiontype = "Motion type: Resolution" ///
			   3.motiontype = "Motion type: Bill" ///
			   1.sponsor_cat ="Sponsor: Government" ///
			   3.sponsor_cat ="Sponsor: Gov. & Opp." ///
			   1.cyc="Timing: 1st year" ///
			   2.cyc="Timing: 2nd year" ///
			   3.cyc="Timing: 3rd year" ///
			   1.final_debate="Bill type: Final debate") ///
	order(1.currenttop 2.motiontype 3.motiontype 1.final_debate) ///
	legend(position(bottom) rows(1)) eform transform(* = min(max(@,0),20)) ///
	xtitle(Odds ratio) title(" ") scheme(plotplain) ///
	note("Dependent variable: Recorded vote" ///
	"Odds ratio with 95% confidence intervals" ///
	"Reference categories: motion type - regular motion; sponsor - opposition; timing - 4th year", size(small) span)
graph export Fig_1_coefplot_request_`date_string'.emf, replace


* A.2.3 Results table
********************
// Table A.1
esttab request_all request_bills using tables_RCV_LSQ_`date_string'.rtf, replace ///
	numbers star b(a3) nobase se notes label ///
	nogaps obslast nodepvars nocons eform ///
	mtitles("All votes except troop deployment" "Votes on bills" ) ///
	title("Table A.1: Explaining RCV request") ///
	coeflabels(1.currenttop "Salient policy area" ///
               2.motiontype "Motion type: Resolution" ///
			   3.motiontype "Motion type: Bill" ///
			   1.sponsor_cat "Sponsor: Government" ///
			   3.sponsor_cat "Sponsor: Gov. & Opp." ///
			   1.cyc "Timing: 1st year" ///
			   2.cyc "Timing: 2nd year" ///
			   3.cyc "Timing: 3rd year" ///
			   1.final_debate "Bill type: Final debate") ///
	note("Dependent variable: Recorded vote." ///
	"Odds rations with standard errors in parentheses." ///
	"Reference categories: motion type - regular motion; sponsor: opposition; timing: 4th year")
	
	
***********************************************************
** B ANALYSIS OF OPPOSITION VOTING BEHAVIOR (PARTY LEVEL)
***********************************************************


use EveryBundestagVote_PartyLevel.dta, clear


** B.0. Preparations
*******************
label var currenttop "Salient policy area"

** B.1. Estimate main models 
***************************

// Opposition behavior on RCVs (Model 3 in Tab A.2)
melogit plgl i.currenttop i.motiontype ib3.sponsor_cat_party  ib4.cyc i.party ///
	if motiontype!=4 & motiontype!=5 & motiontype!=6 & motiontype!=7 ///
	& recorded ==1 ||nr: , or 
estat ic
estat icc
estadd scalar ICC = r(icc2) 
est store RCV

// Opposition behavior on non-recorded votes (Model 4 in Tab. A.2)
melogit plgl i.currenttop i.motiontype ib3.sponsor_cat_party  ib4.cyc i.party ///
	if motiontype!=4 & motiontype!=5 & motiontype!=6 & motiontype!=7 ///
	& recorded == 0 ||nr: , or
estat ic
estat icc
estadd scalar ICC = r(icc2) 
est store Nonrecorded_votes

// Opposition behavior in full sample with voting method as explantory factor
// (Model 5 in Tab. A.2)

melogit plgl i.recorded i.currenttop i.motiontype ib3.sponsor_cat_party ib4.cyc ///
	i.party if motiontype!=4 & motiontype!=5 & motiontype!=6 ///
	& motiontype!=7 ||nr: , or
estat ic
estat icc
estadd scalar ICC = r(icc2) 
est store fullsample

// Opposition behavior in full sample with voting method as explanatory factor
// and interaction terms with other explanatory factors (Model 6 in Table A.3)
melogit plgl i.recorded##i.currenttop i.recorded##i.motiontype ///
	i.recorded##ib3.sponsor_cat_party i.recorded##ib4.cyc i.recorded##i.party ///
	if motiontype!=4 & motiontype!=5 & motiontype!=6 & motiontype!=7 ///
	||nr: , or
estat ic
estat icc
estadd scalar ICC = r(icc2) 
est store fullsample_interactions


** B.2. Coefficient plots (Figure 2 and 3)
*****************************************

// Main effects (Figure 2)
coefplot (RCV, label("(3) Recorded votes")) ///
	(Nonrecorded_votes, label("(4) Nonrecorded votes")) ///
	(fullsample, label("(5) All votes")), xline(1,lcolor(black) lwidth(.2)) ///
	drop(_cons) ///
	coeflabels(1.currenttop = "Salient policy area" ///
               2.motiontype = "Motion type: Resolution" ///
			   3.motiontype = "Motion type: Bill" ///
			   1.sponsor_cat_party = "Sponsor: Government" ///
			   2.sponsor_cat_party = "Sponsor: Own motion" ///
			   1.cyc="Time: 1st year" ///
			   2.cyc="Time: 2nd year" ///
			   3.cyc="Time: 3rd year" ///
			   1.recorded="Recorded vote") ///
   legend(position(bottom) rows(1)) xsize(6) ///
   order(1.currenttop 2.motiontype 3.motiontype 1.final_debate) eform ///
   title("Odds ratios P(Voting agreement with cabinet)") ///
   xtitle(Odds ratio) title(" ") scheme(plotplain) ///
   note("Dependent variable: Voting agreement with government." ///
   "Odds ratio with 95% confidence intervals; random effect on the level of motions included" ///
   "Reference categories: motion type - regular motion; sponsor - other opposition party; timing - 4th year; party - FDP.", size(small) span)
graph export Fig2_coefplot_oppovoting_maineffects_`date_string'.emf, replace

// Interaction effects (Figure 3)
coefplot fullsample_interactions, xline(1, lcolor(black) lwidth(.2)) eform ///
	scheme(plotplain) ///
	keep(1.recorded#1.currenttop 1.recorded#2.motiontype ///
	1.recorded#3.motiontype 1.recorded#1.sponsor_cat_party 1.recorded#2.sponsor_cat_party ///
	1.recorded#1.cyc 1.recorded#2.cyc 1.recorded#3.cyc	///
	1.recorded#5.party 1.recorded#6.party 1.recorded#7.party) ///
	coeflabels(1.recorded#1.currenttop = "RCV X Salient policy area" ///
               1.recorded#2.motiontype = "RCV X Resolution" ///
			   1.recorded#3.motiontype = "RCV X Bill" ///
			   1.recorded#1.sponsor_cat_party = "RCV X Government motion" ///
			   1.recorded#2.sponsor_cat_party = "RCV X Own motion" ///
			   1.recorded#1.cyc="RCV X 1st year" ///
			   1.recorded#2.cyc="RCV X 2nd year" ///
			   1.recorded#3.cyc="RCV X 3rd year" ///
			   1.recorded#5.party = "RCV X Greens" ///
			   1.recorded#6.party ="RCV X Left" ///
			   1.recorded#7.party = "RCV X AfD") ///
	xtitle(Odds ratio) title(" ") ///
	note("Dependent variable: Voting agreement with government." ///
	"Odds ratio with 95% confidence intervals. Main effects and random effect included in the model but not displayed.", size(small) span) 
	
graph export Fig3_coefplot_oppovoting_interactions_`date_string'.emf, replace


** B.3. Results table
***********************

// Table A.2
esttab RCV Nonrecorded_votes fullsample using tables_RCV_LSQ_`date_string'.rtf, ///
	append nogaps nonumbers star b(a3) nobase label se notes ///
	scalar(ICC) obslast nodepvars nocons eform ///
	mtitles("(3) RCV" "(4) Non-recorded votes" "(5) All votes") ///
	title("Table A.2: Explaining vote-agreement between opposition parties and government") ///
	coeflabels(1.currenttop "Salient policy area" ///
               2.motiontype "Motion type: Resolution" ///
			   3.motiontype "Motion type: Bill" ///
			   1.sponsor_cat_party "Sponsor: Government" ///
			   2.sponsor_cat_party "Sponsor: Own motion" ///
			   1.cyc "Timing: 1st year" ///
			   2.cyc "Timing: 2nd year" ///
			   3.cyc "Timing: 3rd year" ///
			   1.recorded "Recorded vote") ///
	note("Dependent variable: Voting agreement with the government." ///
	"Odds rations with standard errors in parentheses; random intercepts on the motion level included." ///
	"Reference categories: motion type - regular motion; sponsor - other opposition party; timing - 4th year; party - FDP")

// Table A.3
esttab fullsample_interactions using tables_RCV_LSQ_`date_string'.rtf, append ///
	nogaps nonumbers star b(a3) nobase label se notes ///
	scalar(ICC) obslast nodepvars nocons eform ///
	mtitle("(6) All votes") ///
	title("Table A.3: Explaining vote-agreement between opposition parties and government: Interaction effects between voting method and explanatory variables") ///
	coeflabels(1.currenttop "Salient policy area" ///
               2.motiontype "Motion type: Resolution" ///
			   3.motiontype "Motion type: Bill" ///
			  1.sponsor_cat_party "Sponsor: Government" ///
			   2.sponsor_cat_party "Sponsor: Own motion" ///
			   1.cyc "Timing: 1st year" ///
			   2.cyc "Timing: 2nd year" ///
			   3.cyc "Timing: 3rd year" ///
			   1.recorded "Recorded vote" ///
			   1.recorded#1.currenttop "RCV X Salient policy area" ///
               1.recorded#2.motiontype "RCV X Resolution" ///
			   1.recorded#3.motiontype "RCV X Bill" ///
			   1.recorded#1.sponsor_cat_party "RCV X Government motion" ///
			   1.recorded#2.sponsor_cat_party "RCV X Own motion" ///
			   1.recorded#1.cyc "RCV X 1st year" ///
			   1.recorded#2.cyc "RCV X 2nd year" ///
			   1.recorded#3.cyc "RCV X 3rd year" ///
			   1.recorded#5.party "RCV X Greens" ///
			   1.recorded#6.party "RCV X Left" ///
			   1.recorded#7.party "RCV X AfD") ///
	note("Dependent variable: Voting agreement with the government." ///
	"Odds rations with standard errors in parentheses; random intercepts on the motion level included." ///
	"Reference categories: motion type - regular motion; sponsor - other opposition party; timing - 4th year; party - FDP")


** B.4. Robustness test: Hypothetical Bundestag without AfD
*********************************************************
* B.4.1 Estimate models without AfD
**********************************

// Opposition behavior on RCVs (Model 7 in Tab A.4)
melogit plgl i.currenttop i.motiontype ib3.sponsor_cat_party  ib4.cyc i.party ///
	if sponsor_cat_party_woafd==1 & party!=7 & motiontype!=4 & motiontype!=5 ///
	& motiontype!=6 & motiontype!=7 & recorded == 1 ||nr: , or
estat ic
estat icc
estadd scalar ICC = r(icc2) 
est store RCV_woAfD

// Opposition behavior on non-recorded votes (Model 8 in Tab. A.4)
melogit plgl i.currenttop i.motiontype ib3.sponsor_cat_party ib4.cyc i.party ///
	if sponsor_cat_party_woafd==1 & party!=7 & motiontype!=4 & motiontype!=5 ///
	& motiontype!=6 & motiontype!=7 & recorded == 0 ||nr: , or
estat ic
estat icc
estadd scalar ICC= r(icc2) 
est store Nonrecorded_votes_woAfD

// Opposition behavior in full sample with voting method as explantory factor
// (Model 9 in Tab. A.4)
melogit plgl i.recorded i.currenttop i.motiontype ib3.sponsor_cat_party ib4.cyc ///
	i.party if sponsor_cat_party_woafd==1 & party!=7 & motiontype!=4 & motiontype!=5 ///
	& motiontype!=6 & motiontype!=7 ||nr: , or
estat ic
estat icc
estadd scalar ICC = r(icc2) 
est store fullsample_woAfD

// Opposition behavior in full sample with voting method as explanatory factor
// and interaction terms with other explanatory factors (Model 10 in Table A.5)
melogit plgl i.recorded##i.currenttop i.recorded##i.motiontype ///
	i.recorded##ib3.sponsor_cat_party i.recorded##ib4.cyc i.recorded##i.party ///
	if sponsor_cat_party_woafd==1 & party!=7 & motiontype!=4 & motiontype!=5 ///
	& motiontype!=6 & motiontype!=7 ||nr: , or
estat ic
estat icc
estadd scalar ICC = r(icc2) 
est store fullsample_inter_woAfD


* B.4.2 Coefficient plots without AfD (Figures A.1 and A.2)
**********************************************************
// Main effects (Figure A.1)
coefplot (RCV_woAfD, label("(7) Recorded votes")) ///
	(Nonrecorded_votes_woAfD, label("(8) Nonrecorded votes")) ///
(fullsample_woAfD, label("(9) All votes")), xline(1,lcolor(black) lwidth(.2)) ///
	drop(_cons) ///
	coeflabels(1.currenttop = "Salient policy area" ///
               2.motiontype = "Motion type: Resolution" ///
			   3.motiontype = "Motion type: Bill" ///
			   1.sponsor_cat_party = "Sponsor: Government" ///
			   2.sponsor_cat_party = "Sponsor: Own motion" ///
			   1.cyc="Time: 1st year" ///
			   2.cyc="Time: 2nd year" ///
			   3.cyc="Time: 3rd year" ///
			   1.recorded="Recorded vote") ///
   legend(position(bottom) rows(1)) xsize(6) ///
   order(1.currenttop 2.motiontype 3.motiontype 1.final_debate) eform ///
   title("Odds ratios P(Voting agreement with cabinet)") ///
   xtitle(Odds ratio) title(" ") scheme(plotplain) ///
   note("Dependent variable: Voting agreement with government." ///
   "Odds ratio with 95% confidence intervals; random effect on the level of motions included" ///
   "Reference categories: motion type - regular motion; sponsor - other opposition party; timing - 4th year; party - FDP.", size(small) span)
graph export FigA1_coefplot_oppovoting_maineffects_woAfD_`date_string'.emf, replace


// Interaction effects (Figure A.2)
coefplot fullsample_inter_woAfD, xline(1, lcolor(black) lwidth(.2)) eform ///
	scheme(plotplain) ///
	keep(1.recorded#1.currenttop 1.recorded#2.motiontype ///
	1.recorded#3.motiontype 1.recorded#1.sponsor_cat_party 1.recorded#2.sponsor_cat_party ///
	1.recorded#1.cyc 1.recorded#2.cyc 1.recorded#3.cyc	///
	1.recorded#5.party 1.recorded#6.party 1.recorded#7.party) ///
	coeflabels(1.recorded#1.currenttop = "RCV X Salient policy area" ///
               1.recorded#2.motiontype = "RCV X Resolution" ///
			   1.recorded#3.motiontype = "RCV X Bill" ///
			   1.recorded#1.sponsor_cat_party = "RCV X Government motion" ///
			   1.recorded#2.sponsor_cat_party = "RCV X Own motion" ///
			   1.recorded#1.cyc="RCV X 1st year" ///
			   1.recorded#2.cyc="RCV X 2nd year" ///
			   1.recorded#3.cyc="RCV X 3rd year" ///
			   1.recorded#5.party = "RCV X Greens" ///
			   1.recorded#6.party ="RCV X Left") ///
	xtitle(Odds ratio) title(" ") ///
	note("Dependent variable: Voting agreement with government." ///
	"Odds ratio with 95% confidence intervals. Main effects and random effect included in the model but not displayed.", size(small) span)
graph export FigA2_coefplot_oppovoting_interactions_woAfD_`date_string'.emf, replace


 
* B.4.3 Results table without AfD
********************************
// Table A.4
esttab RCV_woAfD Nonrecorded_votes_woAfD fullsample_woAfD ///
	using tables_RCV_LSQ_`date_string'.rtf, append nogaps nonumbers star b(a3) nobase ///
	label se notes scalar(ICC) obslast nodepvars nocons eform ///
	mtitles("(7) RCV" "(8) Non-recorded votes" "(9) All votes") ///
	title("Table A.4: Explaining vote-agreement between opposition parties and government (Hypothetical Bundestag without AfD") ///
	coeflabels(1.currenttop "Salient policy area" ///
               2.motiontype "Motion type: Resolution" ///
			   3.motiontype "Motion type: Bill" ///
			   1.sponsor_cat_party "Sponsor: Government" ///
			   2.sponsor_cat_party "Sponsor: Own motion" ///
			   1.cyc "Timing: 1st year" ///
			   2.cyc "Timing: 2nd year" ///
			   3.cyc "Timing: 3rd year" ///
			   1.recorded "Recorded vote") ///
	note("Dependent variable: Voting agreement with the government." ///
	"Odds rations with standard errors in parentheses; random intercepts on the motion level included." ///
	"Reference categories: motion type - regular motion; sponsor - other opposition party; timing - 4th year; party - FDP")


// Table A.5
esttab fullsample_inter_woAfD using tables_RCV_LSQ_`date_string'.rtf, append ///
	nogaps nonumbers star b(a3) nobase label se notes ///
	scalar(ICC) obslast nodepvars nocons eform ///
	mtitle("(10) All votes") ///
	title("Table A.5: Explaining vote-agreement between opposition parties and government: Interaction effects between voting method and explanatory variables (Hypothetical Bundestag without AfD)") ///
	coeflabels(1.currenttop "Salient policy area" ///
               2.motiontype "Motion type: Resolution" ///
			   3.motiontype "Motion type: Bill" ///
			  1.sponsor_cat_party "Sponsor: Government" ///
			   2.sponsor_cat_party "Sponsor: Own motion" ///
			   1.cyc "Timing: 1st year" ///
			   2.cyc "Timing: 2nd year" ///
			   3.cyc "Timing: 3rd year" ///
			   1.recorded "Recorded vote" ///
			   1.recorded#1.currenttop "RCV X Salient policy area" ///
               1.recorded#2.motiontype "RCV X Resolution" ///
			   1.recorded#3.motiontype "RCV X Bill" ///
			   1.recorded#1.sponsor_cat_party "RCV X Government motion" ///
			   1.recorded#2.sponsor_cat_party "RCV X Own motion" ///
			   1.recorded#1.cyc "RCV X 1st year" ///
			   1.recorded#2.cyc "RCV X 2nd year" ///
			   1.recorded#3.cyc "RCV X 3rd year" ///
			   1.recorded#5.party "RCV X Greens" ///
			   1.recorded#6.party "RCV X Left" ///
			   1.recorded#7.party "RCV X AfD") ///
	note("Dependent variable: Voting agreement with the government." ///
	"Odds rations with standard errors in parentheses; random intercepts on the motion level included." ///
	"Reference categories: motion type - regular motion; sponsor - other opposition party; timing - 4th year; party - FDP")

	
log close


********************************************************
** APPENDIX: Additional information on the full dataset
********************************************************

use EveryBundestagVote_VoteLevel.dta, clear


**
* Figure SI.1 Share of recorded votes by electoral cycle year
**
g zaehler=(_n/2)-1 // this variable is only needed for positioning various elements in the SI figures

egen cycmean_all=mean(recorded),by(cyc)
egen cycmean_all_se=sd(recorded),by(cyc)
bysort cyc: generate cyc_hise_all=cycmean_all+(1.96*cycmean_all_se)
bysort cyc: generate cyc_lose_all=cycmean_all-(1.96*cycmean_all_se)
egen cycmean_bills=mean(recorded) if motiontype==3,by(cyc)
egen cycmean_bills_se=sd(recorded),by(cyc)
bysort cyc: generate cyc_hise_bills=cycmean_bills+(1.96*cycmean_bills_se)
bysort cyc: generate cyc_lose_bills=cycmean_bills-(1.96*cycmean_bills_se)
egen cycmean_finaldebate=mean(recorded) if final_debate==1,by(cyc)
egen cycmean_finaldebate_se=sd(recorded),by(cyc)
bysort cyc: generate cyc_hise_finaldebate=cycmean_finaldebate+(1.96*cycmean_finaldebate_se)
bysort cyc: generate cyc_lose_finaldebate=cycmean_finaldebate-(1.96*cycmean_finaldebate_se)
sort cyc

twoway__histogram_gen cyc if motiontype<4 & motiontype!=. & sponsor_cat!=. & currenttop!=. & sponsor_cat!=4 & bundeswehreinsatz==0, freq gen(h_histcyc x_histcyc)
replace h_histcyc=(h_histcyc/10000)
replace x_histcyc=x_histcyc+.1 if x_histcyc>.6 & x_histcyc<1.9

replace x_histcyc=1 if x_histcyc<2 & x_histcyc<1.5
replace x_histcyc=2 if x_histcyc<2 & x_histcyc>1.5
replace x_histcyc=3 if x_histcyc>2 & x_histcyc<3.5
replace x_histcyc=4 if x_histcyc>3.5 & x_histcyc!=.

twoway__histogram_gen cyc if recorded==1 & motiontype<4 & motiontype!=. & sponsor_cat!=. & currenttop!=. & sponsor_cat!=4 & bundeswehreinsatz==0, freq gen(h_histcycr x_histcycr)
replace h_histcycr=(h_histcycr/10000)
replace x_histcycr=x_histcyc 

twoway (spike h_histcyc x_histcyc)  (spike h_histcycr x_histcycr) 

tab cyc recorded if motiontype<4 & motiontype!=. & sponsor_cat!=. & currenttop!=. & sponsor_cat!=4 & bundeswehreinsatz==0

g textcyc="N=248" if zaehler==1
replace textcyc="N=556" if zaehler==2
replace textcyc="N=1016" if zaehler==3
replace textcyc="N=1673" if zaehler==4

g y_cyc=.0248 + 0.01 if zaehler==1 
replace y_cyc=.0556 + 0.01 if zaehler==2 
replace y_cyc=.1016 + 0.01 if zaehler==3
replace y_cyc=.1673 + 0.01 if zaehler==4

g textcycr="N=32" if zaehler==1
replace textcycr="N=58" if zaehler==2
replace textcycr="N=55" if zaehler==3
replace textcycr="N=51" if zaehler==4

g y_cycr=.0032 + 0.005 if zaehler==1 
replace y_cycr=.0058 + 0.005 if zaehler==2 
replace y_cycr=.0055 + 0.005 if zaehler==3
replace y_cycr=.0051 + 0.005 if zaehler==4

twoway (scatter y_cycr zaehler if zaehler<5,msymbol(none) mlabel(textcycr) mlabcolor(black))


twoway ///
(spike h_histcyc x_histcyc if x_histcyc>.6,lwidth(10) lcolor(gs3%20)) (spike h_histcycr x_histcycr if x_histcycr>.6,lwidth(10) lcolor(gs3%95)) (connected cycmean_all cyc if cyc>0,lcolor(gs14) lwidth(.5) mcolor(gs10) msize(1.5) msymbol(D)) (connected cycmean_bills cyc  if cyc>0,lcolor(black) mcolor(black) msize(1.5)) (connected cycmean_finaldebate cyc  if cyc>0,lcolor(gs7) mcolor(gs7) msymbol(Oh) msize(1.5)) (rcap cyc_hise_all cyc_lose_all cyc  if cyc>0,lcolor(gs10)) (rcap cyc_hise_bills cyc_lose_bills cyc  if cyc>0,lcolor(black)) (rcap cyc_hise_finaldebate cyc_lose_finaldebate cyc  if cyc>0,lcolor(gs7)) (scatter y_cyc zaehler if zaehler<4.5 & zaehler>0.75,msymbol(none) mlabel(textcyc) mlabcolor(gs7)) (scatter y_cycr zaehler if zaehler<4.5 & zaehler>0.75,msymbol(none) mlabel(textcycr) mlabcolor(black)),legend(position(bottom) order(3 "All votes" 4 "Bills" 5 "Bills (final debates)") rows(1) region(fcolor(gs3%20))) xtitle("Cycle") ytitle("Share recorded votes") xscale(r(0.75(0.5)4.5)) title("Share of recorded votes by electoral cycle year") scheme(plotplain)
graph export figure_SI1`date_string'.emf, replace


**
* Figure SI.2 Share of motion type by recording status
**
*Motion type for all motions
egen mottotal=count(motiontype),by(recorded)
foreach i in 1 2 3 4 5 6 7 {
egen mot`i'n=count(motiontype) if motiontype==`i',by(recorded)
g mot`i'pcttemp=(mot`i'n/mottotal)*100
egen mot`i'pctr=max(mot`i'pcttemp) if recorded==1
egen mot`i'pctnr=max(mot`i'pcttemp) if recorded==0
g mot`i'pct=mot`i'pctr if recorded==1
replace mot`i'pct=mot`i'pctnr if recorded==0
}


graph bar mot1pct mot2pct mot3pct mot4pct mot5pct mot6pct mot7pct,over(recorded,relabel(1 "Non-recorded" 2 "Recorded")) stack horizontal legend(order(1 "Motion" 2 "Resolution" 3 "Bill" 4 "Election" 5 "Report" 6 "Petition" 7 "Committee referral")position(bottom) rows(1)) bar(1, fcolor(gold%60) lcolor(black%60)) bar(2, fcolor(black%60) lcolor(black%60)) bar(3, fcolor(cyan%60) lcolor(black%60)) bar(4, fcolor(dkgreen%80) lcolor(black%60)) bar(5, fcolor(pink%80) lcolor(black%60)) bar(6, fcolor(orange%80) lcolor(black%60)) bar(7, fcolor(lime%60) lcolor(black%60)) ytitle("Percent") title("Share of motion type by recording status") scheme(plotplain)
graph export figure_SI2`date_string'.emf, replace

**
* Figure SI.3
**
egen initstacktotal=count(sponsor_cat),by(recorded)
foreach i in 1 2 3 4 5 {
egen initstack`i'n=count(sponsor_cat) if sponsor_cat==`i',by(recorded)
g initstack`i'pcttemp=(initstack`i'n/initstacktotal)*100
egen initstack`i'pctr=max(initstack`i'pcttemp) if recorded==1
egen initstack`i'pctnr=max(initstack`i'pcttemp) if recorded==0
g initstack`i'pct=initstack`i'pctr if recorded==1
replace initstack`i'pct=initstack`i'pctnr if recorded==0
}

graph bar initstack1pct initstack2pct initstack3pct initstack4pct initstack5pct,over(recorded,relabel(1 "Non-recorded" 2 "Recorded")) stack horizontal legend(order(1 "Gov" 2 "Opp" 3 "Gov & Opp" 4 "Petition")position(bottom) rows(1)) bar(1, fcolor(gold%60) lcolor(black%60)) bar(2, fcolor(black%60) lcolor(black%60)) bar(3, fcolor(cyan%60) lcolor(black%60)) bar(4, fcolor(dkgreen%80) lcolor(black%60)) bar(5, fcolor(pink%80) lcolor(black%60)) bar(6, fcolor(orange%80) lcolor(black%60)) bar(7, fcolor(lime%60) lcolor(black%60))  ytitle("Percent") title("Share of sponsor by recording status") scheme(plotplain)
graph export figure_SI3`date_string'.emf, replace

**
* Figure SI.4
**
egen cycstacktotal=count(cyc),by(recorded)
foreach i in 0 1 2 3 4 {
egen cycstack`i'n=count(sponsor_cat) if cyc==`i',by(recorded)
g cycstack`i'pcttemp=(cycstack`i'n/cycstacktotal)*100
egen cycstack`i'pctr=max(cycstack`i'pcttemp) if recorded==1
egen cycstack`i'pctnr=max(cycstack`i'pcttemp) if recorded==0
g cycstack`i'pct=cycstack`i'pctr if recorded==1
replace cycstack`i'pct=cycstack`i'pctnr if recorded==0
}

graph bar cycstack1pct cycstack2pct cycstack3pct cycstack4pct,over(recorded,relabel(1 "Non-recorded" 2 "Recorded")) stack horizontal legend(order(1 "1st year" 2 "2nd year" 3 "3rd year" 4 "4th year")position(bottom) rows(1)) bar(1, fcolor(gold%60) lcolor(black%60)) bar(2, fcolor(black%60) lcolor(black%60)) bar(3, fcolor(cyan%60) lcolor(black%60)) bar(4, fcolor(dkgreen%80) lcolor(black%60)) bar(5, fcolor(pink%80) lcolor(black%60)) bar(6, fcolor(orange%80) lcolor(black%60)) bar(7, fcolor(lime%60) lcolor(black%60))  ytitle("Percent") title("Timing of votes by recording status") scheme(plotplain)
graph export figure_SI4`date_string'.emf, replace


**
* Figure SI.5 
**
**Unanimous votes by category
foreach i in 1 2 3 4 5 6 7 {
mean unisonvote if motiontype==`i'
g mean_motuna`i'=e(b)[1,1]
g sd_motuna`i'=e(sd)[1,1]
g n_motuna`i'=e(N)
g se_motuna`i'=sd_motuna`i'/sqrt(n_motuna`i') 
g hi_motuna`i'=mean_motuna`i'+(1.96*se_motuna`i') 
g lo_motuna`i'=mean_motuna`i'-(1.96*se_motuna`i')
tab hi_motuna`i' lo_motuna`i'
}

twoway ///
(bar mean_motuna1 zaehler if zaehler==1,bcolor(white) blcolor(black) barwidth(.5) blwidth(.3)) (rcap hi_motuna1 lo_motuna1 zaehler if zaehler==1,lcolor(gs7) lwidth(.4)) ///
(bar mean_motuna2 zaehler if zaehler==2,bcolor(white) blcolor(black) barwidth(.5) blwidth(.3)) (rcap hi_motuna2 lo_motuna2 zaehler if zaehler==2,lcolor(gs7) lwidth(.4)) ///
(bar mean_motuna3 zaehler if zaehler==3,bcolor(white) blcolor(black) barwidth(.5) blwidth(.3)) (rcap hi_motuna3 lo_motuna3 zaehler if zaehler==3,lcolor(gs7) lwidth(.4)) ///
(bar mean_motuna4 zaehler if zaehler==4,bcolor(white) blcolor(black) barwidth(.5) blwidth(.3)) (rcap hi_motuna4 lo_motuna4 zaehler if zaehler==4,lcolor(gs7) lwidth(.4)) ///
(bar mean_motuna5 zaehler if zaehler==5,bcolor(white) blcolor(black) barwidth(.5) blwidth(.3)) (rcap hi_motuna5 lo_motuna5 zaehler if zaehler==5,lcolor(gs7) lwidth(.4)) ///
(bar mean_motuna6 zaehler if zaehler==6,bcolor(white) blcolor(black) barwidth(.5) blwidth(.3)) (rcap hi_motuna6 lo_motuna6 zaehler if zaehler==6,lcolor(gs7) lwidth(.4)) ///
(bar mean_motuna7 zaehler if zaehler==7,bcolor(white) blcolor(black) barwidth(.5) blwidth(.3)) (rcap hi_motuna7 lo_motuna7 zaehler if zaehler==7,lcolor(gs7) lwidth(.4)) ///
(scatter mean_motuna1 zaehler if zaehler==1,msymbol(none) mlabel(n_motuna1) mlabposition(1)) ///
(scatter mean_motuna2 zaehler if zaehler==2,msymbol(none) mlabel(n_motuna2) mlabposition(1)) ///
(scatter mean_motuna3 zaehler if zaehler==3,msymbol(none) mlabel(n_motuna3) mlabposition(1)) ///
(scatter mean_motuna4 zaehler if zaehler==4,msymbol(none) mlabel(n_motuna4) mlabposition(1)) ///
(scatter mean_motuna5 zaehler if zaehler==5,msymbol(none) mlabel(n_motuna5) mlabposition(1)) ///
(scatter mean_motuna6 zaehler if zaehler==6,msymbol(none) mlabel(n_motuna6) mlabposition(1)) ///
(scatter mean_motuna7 zaehler if zaehler==7,msymbol(none) mlabel(n_motuna7) mlabposition(1)) ///
, xlabel(1 "Motion" 2 "Resolution" 3 "Bill" 4 "Election" 5 "Report" 6 "Petition" 7 "Committee referral",angle(45)) legend(off) ytitle("% unanimous votes") title("% unanimous votes by motion type") yline(.4212,lpattern(dash) lcolor(gs7) lwidth(1)) xtitle("Motion type") name(unanimousshare_by_motiontype,replace) scheme(plotplain)
graph export figure_SI5`date_string'.emf, replace
/*